{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/caseuploadcheck/index.css" />
    <style>
        .modal.in .modal-dialog{
            transform: translate(0,50%)!important;
        }
    </style>
{/block}
{block name="page_section"}
    <div>
        <div class="sessionPage">

              <ul class="nav nav-tabs" style="width:95%;margin: 10px auto;">
                  <li {if $source == 1} class="active"{/if}><a href="/caseaudit/index?source=1" style="color:#1D2129;font-size: 15px"><b>导入审核</b></a></li>
                  <li {if $source == 2} class="active"{/if}><a href="/caseaudit/index?source=2" style="color:#1D2129;font-size: 15px"><b>推送审核</b></a></li>
              </ul>
            <form class="small-style" method="get" action="" role="validform" enctype="multipart/form-data">
              <div class="form_row">
                <input type="hidden" name="is_show" class="showmoreishow" value="{if $is_show == 1}1{else}0{/if}">
                <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
                <div class="form-group col-lg-3 ui-select">
                    <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
                    <div class="col-sm-7">
                        <select class="form-control selectpicker"    title="请选择" name="mediationOrganId" id="mediationOrganId">
                            {foreach from=$mediationOrgan  item=info}
                                <option class="u144_input_option" {if !empty($query.mediationOrganId) &&  $info.id== $query.mediationOrganId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group col-lg-3 ui-select">
                    <label for="exampleInputName2"  class="col-sm-4 control-label">资产方:</label>
                    <div class="col-sm-7">
                        <select class="form-control selectpicker"   title="请选择" name="assetsId" id="assetsId">
                            {foreach from=$assets  item=info}
                                <option class="u144_input_option" {if !empty($query.assetsId) &&  $info.id == $query.assetsId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group col-lg-3 ui-select">
                    <label for="exampleInputName2"  class="col-sm-4 control-label">导入批次ID:</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.importRecordId)}{$query.importRecordId}{/if}" name="importRecordId" id="importRecordId" placeholder="请输入~">
                    </div>
                </div>
                  <div class="form-group col-lg-3 ui-select">
                      <label for="exampleInputName2"  class="col-sm-4 control-label">批次名称:</label>
                      <div class="col-sm-7">
                          <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batchName)}{$query.batchName}{/if}" name="batchName" id="batchName" placeholder="请输入~">
                      </div>
                  </div>

              </div>
              <div class="form_row">
                  <div class="form-group col-lg-3 ui-select">
                      <label for="exampleInputName2"  class="col-sm-4 control-label">案件标识号:</label>
                      <div class="col-sm-7">
                          <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batshId)}{$query.batshId}{/if}" name="batshId" id="batshId" placeholder="请输入~">
                      </div>
                  </div>
                <div class="form-group col-lg-3 ui-select">
                    <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
                    </div>
                </div>
                <div class="form-group col-lg-3 ui-select">
                    <label class="col-sm-4 control-label">
                        入库时间:
                    </label>
                    <div class="col-sm-7">
                         <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
                    </div>
                </div>
                <div class="form-group col-lg-3 ui-select">
                    <div class="col-lg-5">
                        <button class="btn btn-primary col-lg-8 shousuoBtn "><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
                    </div>
                    <div class="col-lg-5">
                        <a type="button" href="/caseaudit/index?source={$source}" class="btn btn-default col-lg-8 "><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
                    </div>
                </div>
              </div>
            </form>
            <div style="width: 95%;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            overflow-x: scroll;">
                <table class="table table-striped table-bordered table-hover text-nowrap" id="tab">
                <thead>
                <tr>

                    <th><input type="checkbox" class="checkall" style="vertical-align: text-bottom"></th>
                    <th>案件ID</th>
                    <th>调解部门</th>
                    <th>资产方</th>
                    <th>当事人</th>
                    <th>案件类型</th>
                    {if $source == 1} <th>批次名称</th>{/if}
                    <th>借款平台</th>
                    <th>借款期数</th>
                    <th>欠款总额</th>
                    <th>诉求金额</th>
                    <th>逾期时间</th>
                    <th>入库时间</th>
                    <th class="fix-ele">操作</th>

                </thead>
                <tbody>
                {foreach from=$arrList item=item name=foo}
                    <tr>
                        <td> <input name="checkItem" class="j-check" type="checkbox" value="{$item.id}"></td>
                        <td>{$item.id}</td>
                        <td>{$mediationOrgan[$item.mediationOrganId]['name']}</td>
                        <td>{$assets[$item.assetsId]['name']} </td>
                        <td>{$item.litigantName}</td>
                        <td><p
                                {if $item.caseType == 2}
                                style="color: #77c87a;background-color:#ecf5ec;padding: 3px 4px;border-radius:5px"
                                {elseif $item.caseType == 3}
                                style="color: #FF5460;background-color:#fff4f9;padding: 3px 4px;border-radius:5px"
                                {else}
                                style="color: #03A9F4;background-color:#e2eef6;padding: 3px 4px;border-radius:5px"
                                {/if}
                            >{$caseType[$item.caseType]}</p></td>
                        {if $source == 1} <th>{$item.batchName}</th>{/if}
                        <td>{$item.loanPlatform}</td>
                        <td>{$item.loanTerm}</td>
                        <td>{$item.debtTotal}</td>
                        <td>{$item.claimAmount}</td>
                        <td>{$item.overdueDate|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                        <td>{$item['addTime']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                        <td class="text-nowrap fix-ele">
                             <a href="/caseinfo/caseinfo?caseId={$item['id']}">详情</a >
                        </td>
                    </tr>
                {/foreach}
                </tbody>
            </table>
            </div>
            <div class="mr-b20 col-lg-12 pad-no" style="float:none;">
                <input type="button" value="审核通过" data-toggle="modal" data-target="#export_modal_submitCase" class="btn btn-primary casesubmit" case_status="pass">
                <input type="button" value="审核驳回" data-toggle="modal" data-target="#export_modal_submitCase" class="btn btn-primary casesubmit" case_status="reject">
            </div>
            <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
                {include file="base/pagenav.html"  action="/caseaudit/index" pagenum=$curPageNum inline}
                <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
                    <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
                    <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
                    <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
                    <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
                    <option value="limit=500" {if $query.limit==500}selected="selected"{/if}>500/页</option>
                    <option value="limit=1000" {if $query.limit==1000}selected="selected"{/if}>1000/页</option>
                    <option value="limit=2000" {if $query.limit==2000}selected="selected"{/if}>2000/页</option>
                </select>
                <span style="float:right;">欠款总额 {number_format($debtTotal,2)} 元，本金总额 {number_format($debtAmount,2)} 元，共 {$groupTotal} 人，共 {$totalnum} 件</span>
             </div>
        </div>

    <div class="modal fade" id="export_modal_submitCase" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">案件审核</h4>
                </div>
                <div class="modal-body">
                    <form id="withdraw_form">
                        <p> 即将 <span style="color: green" id="chean_num"></span> 件案件审核 <span style="color: red" id="audit_status"></span> ,请确认是否继续!<p >
                        <input type="hidden" value="" id="case_audit_status" name="case_audit_status">
                    </form>
                </div>
                <div class="modal-footer" style="text-align: center;">
                    <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary distribution">确定</button>
                </div>
            </div>
        </div>
    </div>

{/block}
{block name="page_scripts"}
<script type="text/javascript" src="/js/mediation/caseaudit/index.min.js" init="mediation/caseaudit/index"></script>
<script type="text/javascript" src="/js/module/date.js"></script>
<script type="text/javascript">
     $(".casesubmit").on("click",function(){
        var arrbtn = [];
        $(".j-check:checked").each(function (index, ele) {
            //遍历所有复选框，然后取值进行 !非操作
            if ($(this).prop("checked")) {
                arrbtn.push($(this).val());
            }
        })
        if(arrbtn.length==0){
            toastr.error('请选择案件');
            return false;
        }
        $("#case_audit_status").val($(this).attr('case_status'));

        $("#chean_num").text(arrbtn.length);
        if($(this).attr('case_status') == 'pass'){
          $("#audit_status").text("通过");
        }else{
          $("#audit_status").text("驳回");
        }

    });

      function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    $('body').on('change','#paglimit', function(){
        console.log()
        var mediationOrganId = GetQueryString('mediationOrganId');
        var paglimit = GetQueryString('limit');
        var source = GetQueryString('source');
        var val =  $(this).val();
          if(!mediationOrganId){
               if(!paglimit && source){
                    window.location = window.location.href+'&'+val;
                }else if(!paglimit){
                    window.location = window.location.href+'?'+val;
                }else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
    })

</script>
{/block}
